import Vue from 'vue'
import Vuex from 'vuex'
import defaultSettings from '@src/config/settings.json'

Vue.use(Vuex)

const themeColor = localStorage.getItem('theme_color')

const store = new Vuex.Store({
  state: {
    settings: {
      ...defaultSettings,
      themeColor: themeColor || defaultSettings.themeColor
    }
  },
  mutations: {
    SET_DEFAULT_SETTINGS(state, payload) {
      state.settings.themeColor = payload
    }
  },
  getters: {
    themeColor: (state) => state.settings.themeColor,
    title: (state) => state.settings.title
  }
})

export default store
